

import java.util.Scanner;

public class 猜拳 {
    public static void main(String[] args) {
        int draw = 0;  //总共平局了多少次
        int win = 0;  //总共赢了多少次
        int lose = 0;  //总共输了多少次
        Scanner sc = new Scanner(System.in);

        String flag = "yes";
        while (flag.equals("yes")){
            int computerNum = (int)(Math.random() * 3);
            System.out.println("开始石头、剪刀、布，请输入");
            String computer = computerGet(computerNum);
            String me = sc.next();
            System.out.print("你出了"+me+"，电脑出了"+computer);
            if (me.equals("石头")&&computer.equals("剪刀")){
                win++;
                System.out.println("\t  你赢了");
            }else if(me.equals("石头")&&computer.equals("布")){
                lose++;
                System.out.println("\t  你输了");
            }else if(me.equals("石头")&&computer.equals("石头")){
                draw++;
                System.out.println("\t  平局");
            }else if(me.equals("剪刀")&&computer.equals("石头")){
                lose++;
                System.out.println("\t  你输了");
            }else if(me.equals("剪刀")&&computer.equals("剪刀")){
                draw++;
                System.out.println("\t  平局");
            }else if(me.equals("剪刀")&&computer.equals("布")){
                win++;
                System.out.println("\t  你赢了");
            }else if(me.equals("布")&&computer.equals("布")){
                draw++;
                System.out.println("\t  平局");
            }else if(me.equals("布")&&computer.equals("剪刀")){
                lose++;
                System.out.println("\t  你输了");
            }else if(me.equals("布")&&computer.equals("石头")){
                win++;
                System.out.println("\t  你赢了");
            }

            System.out.println("你还想继续游戏吗（yes/no）");
            String gamec = sc.next();
            flag = gamec;
        }

        System.out.println("你赢了"+win+"次，输了"+lose+"次，平局"+draw+"次");

    }

    //通过输入随机数来输出石头剪刀布
    public static String computerGet(int computer){
        String computerStr = "";
        switch (computer){
            case 0:
                computerStr = "石头";
                break;
            case 1:
                computerStr = "剪刀";
                break;
            case 2:
                computerStr = "布";
                break;
        }
        return computerStr;
    }
}
